package com.pharmacy.mapper;


import com.github.pagehelper.Page;
import com.pharmacy.annotation.AutoFill;
import com.pharmacy.dto.EmployeesPageSelectDto;
import com.pharmacy.entity.Employees;
import com.pharmacy.enumeration.OperationType;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;



@Mapper
public interface EmployeesMapper {

    /**
     * 查询用户信息
     * @param username
     * @return
     */

    @Select("select * from employees where username = #{username}")
    Employees login(String username);

    /**
     * 新增员工
     * @param employees
     */
    @Insert("INSERT INTO employees (username, name, password, phone, gender, id_card, status, updated_at, created_at, created_by, updated_by) " +
            "VALUES (#{username}, #{name}, #{password}, #{phone}, #{gender}, #{idCard}, #{status}, #{updatedAt}, #{createdAt}, #{createdBy}, #{updatedBy})")
    @AutoFill(value = OperationType.INSERT)
    void addEmployees(Employees employees);

    /**
     * 删除员工
     * @param id
     */
    @Delete("delete from employees where id = #{id}")
    void deleteEmployees(Long id);

    /**
     * 更新员工信息
     * @param employees
     */
    @AutoFill(value = OperationType.UPDATE)
    void updateEmployees(Employees employees);


    /**
     * 分页查询
     * @param employeesPageSelectDto
     * @return
     */
    Page<Employees> pageEmployeesSelect(EmployeesPageSelectDto employeesPageSelectDto);


    /**
     * 根据id查询员工
     * @param id
     * @return
     */
    @Select("select * from employees where id = #{id}")
    Employees getById(Integer id);
}
